#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->wid_view_game->setVisible(false);
    m_browser = new QWebView();
    ui->lay_princ->addWidget(m_browser);
    m_browser->setVisible(false);
    m_browser->load(QUrl("http://www.google.com/"));
    m_browser->setMinimumWidth(1700);
    QObject::connect(ui->table_library, SIGNAL(itemSelectionChanged()), this, SLOT(change_widget()));
    QObject::connect(ui->list_features, SIGNAL(currentRowChanged(int)), this, SLOT(change_view(int)));
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::change_widget()
{
    ui->wid_view_game->setVisible(true);
}

void MainWindow::change_view(int row)
{
    ui->wid_view_game->setVisible(false);
    if (ui->list_features->item(row)->text() == "Library")
    {
        ui->table_library->setVisible(true);
        m_browser->setVisible(false);
    }
    else if (ui->list_features->item(row)->text() == "Store")
    {
        ui->table_library->setVisible(false);
        m_browser->setVisible(true);

    }
}
